package com.Controller;

import com.Service.SNService;
import com.Service.consultanterService;
import com.bean.consultanter;
import com.bean.stuMind;
import com.bean.student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/stu")
public class StuController {

    @Autowired
    private SNService snService;

    @Autowired
    private consultanterService conService;

    /*
    * 学生插入跳转到插入页面
    * */
    @RequestMapping("/insert")
    public String insertHtml(){
        return "studentAdd";
    }

    /*
    *
    * 接受插入的信息并且提交到数据库里
    * */
    @RequestMapping("/add")
    public  String toAdd(stuMind sm){
        System.out.println(sm.toString());
        snService.add(sm);
        System.out.println("插入成功");
        return "redirect:/stu/insert";
    }
    /*
    *
    * 查看现有教师信息
    * */
    @RequestMapping("/teacher")
     public String toSelece(Model model){
        List<consultanter> lists= conService.findAll();
        model.addAttribute("lists",lists);
        return "consultanterList";
    }

}
